package com.mashensoft;

import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;

public class HelloWorld implements ModelDriven<User> {

	private User user = new User();

	public User getModel() {
		return user;
	}

	// private User user1;
	//
	// public User getUser() {
	// return user1;
	// }
	//
	// public void setUser(User user) {
	// this.user1 = user;
	// }

	private List<User> userList;

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	Map<String, String> map;

	public Map<String, String> getMap() {
		return map;
	}

	public void setMap(Map<String, String> map) {
		this.map = map;
	}

	Map<String, User> userMap;

	public Map<String, User> getUserMap() {
		return userMap;
	}

	public void setUserMap(Map<String, User> userMap) {
		this.userMap = userMap;
	}

	public String execute() {
		// 客户端请求头
		HttpServletRequest request = ServletActionContext.getRequest();
		// Enumeration<String> names = request.getHeaderNames();
		// while (names.hasMoreElements()) {
		// String name = names.nextElement();
		// System.out.print(name + "=");
		// System.out.println(request.getHeader(name));
		// }
		// 客户端请求的内容(参数)
		// System.out.println(request.getParameter("name"));
		System.out.println("姓名=" + user.getName());
		System.out.println("密码=" + user.getPassword());
		// System.out.println("map:" + map.get("name"));
		// System.out.println("userMap:" + userMap.get("haha").getPassword());
		// System.out.println("User、" + getUser().getName());
		// System.out.println("User、" + getUser().getPassword());
		//
		// System.out.println("UserList、" + getUserList().get(0).getName());
		// System.out.println("UserList、" + getUserList().get(0).getPassword());

		HttpServletResponse response = ServletActionContext.getResponse();
		// System.out.println("Hello World");
		return "Hello";
	}

}
